﻿//玩家
package com.victim.snake.player{
	import flash.events.EventDispatcher;
	import com.victim.snake.room.Group;
	
	public class Player extends EventDispatcher{
		private var userName:String="";
		private var uid:int=0;
		private var isReady:Boolean=false;	//是否准备
		private var autoReady:Boolean=false;	//是否自动准备
		private var snakeStyle:String;	//蛇样式
		//private var team:int=0;	//队伍 （0:红	1:绿		2:黄		3:蓝）
		private var group:Group = null;	//所属队伍	队伍ID（0:红	1:绿		2:黄		3:蓝）
		public var goLeftKeyCode:uint=83;
		public var goRightKeyCode:uint=68;
		
		
		public function Player(){
			
		}
		
		public function getIsReady():Boolean{
			return this.isReady;
		}
		
		public function setIsReady(bol:Boolean):void{
			this.isReady=bol;
			//抛出准备状态改变事件
			var playerEvent:PlayerEvent=null;
			if(bol){
				playerEvent=new PlayerEvent(PlayerEvent.Ready,this);
			}else{
				playerEvent=new PlayerEvent(PlayerEvent.UnReady,this);
			}
			this.dispatchEvent(playerEvent);
		}
		
		public function getAutoReady():Boolean{
			return this.autoReady;
		}
		
		public function setAutoReady(bol:Boolean):void{
			this.autoReady=bol;
			//trace(autoReady);
			//抛出自动准备状态改变事件
			var playerEvent:PlayerEvent=null;			
			playerEvent=new PlayerEvent(PlayerEvent.AutoReadyChange,this);
			this.dispatchEvent(playerEvent);
		}

		public function getUserName():String{
			return this.userName;
		}
		
		public function setUserName(userName:String):void{
			this.userName=userName;
		}
		
		public function getUid():int{
			return this.uid;
		}
		
		public function setUid(id:int):void{
			this.uid=id;
		}
		
		
		
		public function getSnakeStyle():String{
			return this.snakeStyle;
		}
		
		public function getGroup():Group{
			return this.group;
		}
		public function setGroup(group:Group):void{
			this.group=group;
			this.dispatchEvent(new PlayerEvent(PlayerEvent.SnakeGroupChange,this));
		}
		
		public function setSnakeStyle(snakeStyle:String):void{
			this.snakeStyle=snakeStyle;
			//抛出蛇样式改变事件
			var playerEvent:PlayerEvent=null;			
			playerEvent=new PlayerEvent(PlayerEvent.SnakeStyleChange,this);
			this.dispatchEvent(playerEvent);
		}
	}
}